/**1. async */

async function test() {
  return 'halang'
}
const str = test()
console.log(str) // Promise { 'halang' } 带有async的函数，一定要返回一个peomise

str.then(res => {
  console.log('---res--')
  console.log(res)  // halang
})

async function test2() {
  await 'halang2'
}
console.log('--test2--')
console.log(test2()) // Promise { <pending> }


async function test3() {
  return new Promise( (resolve, reject) => {
    setTimeout(() => {
      const r = Math.random()
      if(r< 0.5) {
        reject(r)
      } else{
        resolve(r)
      }
    }, 1000) 
  } ) 
}
